﻿@model ProductModel.TierPriceModel

@{
    var parentModel = ViewData["Parent"] as ProductModel;
}

<datagrid id="tierprices-grid"
          max-height="800px"
          allow-resize="true"
          allow-row-selection="true"
          allow-edit="true"
          allow-column-reordering="true">
    <datasource read="@Url.Action("TierPriceList", new { productId = parentModel.Id })"
                delete="@Url.Action("TierPriceDelete")"
                update="@Url.Action("TierPriceUpdate")"
                insert="@Url.Action("TierPriceInsert", new { productId = parentModel.Id })" />
    <paging position="Bottom" page-index="1" show-size-chooser="false" />
    <sorting enabled="true" allow-multisort="true">
        <sort by="StoreId" />
        <sort by="Quantity" />
        <sort by="CustomerRoleId" />
    </sorting>
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.InsertRow" type="button" class="btn btn-primary btn-flat no-anims mr-auto">
                <i class="fa fa-plus"></i>
                <span>@T("Admin.Common.AddNew")</span>
            </button>
            <button datagrid-action="DataGridToolAction.SaveChanges" type="button" class="btn btn-warning no-anims btn-flat">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.SaveChanges")</span>
            </button>
            <button datagrid-action="DataGridToolAction.CancelEdit" type="button" class="btn btn-light btn-flat mr-auto">
                <span>@T("Common.Cancel")</span>
            </button>
        </toolbar-group>
        <zone name="datagrid_toolbar_alpha"></zone>
        <toolbar-group class="omega"></toolbar-group>
        <zone name="datagrid_toolbar_omega"></zone>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.DeleteSelectedRows" type="button" class="btn btn-danger no-anims btn-flat">
                <i class="far fa-trash-can"></i>
                <span>@T("Admin.Common.Delete.Selected")</span>
            </button>
        </toolbar-group>
    </toolbar>
    <columns>
        <column for="Quantity" halign="center" hideable="false" width="minmax(100px, auto)" />
        <column for="Price1" halign="flex-end" entity-member="Price" width="minmax(150px, auto)" />
        <column for="CalculationMethodId" width="1fr" entity-member="CalculationMethod">
            <display-template>
                <div class="dg-cell-value">{{ item.row.CalculationMethod }}</div>
            </display-template>
        </column>
        <column for="StoreId" width="1fr">
            <display-template>
                <div class="dg-cell-value">{{ item.row.Store }}</div>
            </display-template>
        </column>
        <column for="CustomerRoleId" width="1fr">
            <display-template>
                <div class="dg-cell-value">{{ item.row.CustomerRole }}</div>
            </display-template>
        </column>
    </columns>
    <row-commands>
        <a datarow-action="DataRowAction.InlineEdit">@T("Common.Edit")</a>
        <a datarow-action="DataRowAction.Delete">@T("Common.Delete")</a>
    </row-commands>
</datagrid>
